package com.example.blogdemo1.mapper;

import com.example.blogdemo1.common.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/*
 * @author zzr
 * @date: 2025/10/05  18:09
 * @description:
 */
@Mapper
public interface BlogMapper {

    /**
     * 返回博客列表
     * @return
     */
    @Select("select * from blog_info where delete_flag = 0")
    List<BlogInfo> selectAll();

    /**
     * 根据博客ID，返回博客信息
     * @param id
     * @return
     */
    @Select("select * from blog_info where id = #{id} and delete_flag = 0")
    BlogInfo selectById(Integer id);

    /**
     * 更新博客
     * @param blogInfo
     * @return
     */
    Integer updateBlog(BlogInfo blogInfo);


    @Insert("insert into blog_info (title, content, user_id) values " +
            "(#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);

}
